package com.shop2cn.iapi.sqoptrade.parameter.vo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.shop2cn.iapi.sqoptrade.parameter.utill.Utils;

public class OrderVoForTax {

	private Long goodsOwnerId;
	
	private List<OrderItemVoForTax> orderItems;
	
	private BigDecimal orderDiscount;
	
	// 总成交价
	private BigDecimal totalProductPrice = BigDecimal.ZERO;
	
	private BigDecimal freight;
	
	/**
     * 区域折扣比例
     */
    private BigDecimal regionDiscountRatio;
	
	// 订单里各订单项关于折扣的权重
	private List<BigDecimal> orderItemWeightsOnDiscount = new ArrayList<BigDecimal>();
	
	// 享受的商家优惠金额
	private BigDecimal sellerPromotionAmount = BigDecimal.ZERO;
	
	// 该订单使用的商家优惠券码
	private String sellerCouponCode;
	
	// 该订单分摊到的商家优惠券面值
	private BigDecimal sellerCouponValue = BigDecimal.ZERO;
	
	// 该订单分摊到的区域折扣
	private BigDecimal regionDiscountValue = BigDecimal.ZERO;
	
	// 使用了商家优惠券的总成交价
	private BigDecimal totalProductPriceInSellerCoupon = BigDecimal.ZERO;
	
	// 订单里各订单项关于商家优惠券的权重
	private List<BigDecimal> orderItemWeightsOnSellerCoupon = new ArrayList<BigDecimal>();
	
	// 订单里各订单项关于区域折扣的权重
	private List<BigDecimal> orderItemWeightsOnRegionDiscount = new ArrayList<BigDecimal>();
	
	// 卖家优惠券来源：0/null：越洋电铺，1：中免大会员
	private Integer sellerCouponSource;

	// 卖家券类型：0/null：满减券，1：满折券，2：代金券
	private Integer sellerCouponType;

	public Long getGoodsOwnerId() {
		return goodsOwnerId;
	}

	public void setGoodsOwnerId(Long goodsOwnerId) {
		this.goodsOwnerId = goodsOwnerId;
	}

	public List<OrderItemVoForTax> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<OrderItemVoForTax> orderItems) {
		this.orderItems = orderItems;
	}

	public BigDecimal getOrderDiscount() {
		return orderDiscount;
	}

	public void setOrderDiscount(BigDecimal orderDiscount) {
		this.orderDiscount = orderDiscount;
	}

	public List<BigDecimal> getOrderItemWeightsOnDiscount() {
		return orderItemWeightsOnDiscount;
	}

	public void setOrderItemWeightsOnDiscount(
			List<BigDecimal> orderItemWeightsOnDiscount) {
		this.orderItemWeightsOnDiscount = orderItemWeightsOnDiscount;
	}
	
	public BigDecimal getTotalProductPrice() {
		return totalProductPrice;
	}

	public void setTotalProductPrice(BigDecimal totalProductPrice) {
		this.totalProductPrice = totalProductPrice;
	}

	public BigDecimal getFreight() {
		return freight;
	}

	public void setFreight(BigDecimal freight) {
		this.freight = freight;
	}

	public BigDecimal getSellerPromotionAmount() {
		return sellerPromotionAmount;
	}

	public void setSellerPromotionAmount(BigDecimal sellerPromotionAmount) {
		this.sellerPromotionAmount = sellerPromotionAmount;
	}
	
	/**
	 * 订单剩余最大可优惠金额
	 *
	 * @return
	 */
	public BigDecimal calcMaxPromotionLeft() {
		BigDecimal result = getTotalProductPrice()
				.subtract(new BigDecimal("0.01"))
				// 每个订单，用户至少需要付1分钱
				.subtract(Utils.zeroIfNull(sellerCouponValue))
				.subtract(Utils.zeroIfNull(sellerPromotionAmount));
		if (result.compareTo(BigDecimal.ZERO) < 0) {
			return BigDecimal.ZERO;
		}
		return result;

	}

	/**
	 * 订单剩余最大可优惠金额
	 *
	 * @return
	 */
	public BigDecimal calcMaxPromotionLeftAndFreight() {
		BigDecimal result = getTotalProductPrice().add(freight)
				.subtract(new BigDecimal("0.01"))
				//每个订单，用户至少需要付1分钱
		.subtract(Utils.zeroIfNull(sellerCouponValue))
		.subtract(Utils.zeroIfNull(sellerPromotionAmount));
		if (result.compareTo(BigDecimal.ZERO) < 0) {
			return BigDecimal.ZERO;
		}
		
		return result;
	}

	public BigDecimal getTotalProductPriceInSellerCoupon() {
		return totalProductPriceInSellerCoupon;
	}

	public void setTotalProductPriceInSellerCoupon(
			BigDecimal totalProductPriceInSellerCoupon) {
		this.totalProductPriceInSellerCoupon = totalProductPriceInSellerCoupon;
	}

	public List<BigDecimal> getOrderItemWeightsOnSellerCoupon() {
		return orderItemWeightsOnSellerCoupon;
	}

	public void setOrderItemWeightsOnSellerCoupon(
			List<BigDecimal> orderItemWeightsOnSellerCoupon) {
		this.orderItemWeightsOnSellerCoupon = orderItemWeightsOnSellerCoupon;
	}

	public BigDecimal getSellerCouponValue() {
		return sellerCouponValue;
	}

	public void setSellerCouponValue(BigDecimal sellerCouponValue) {
		this.sellerCouponValue = sellerCouponValue;
	}

	public String getSellerCouponCode() {
		return sellerCouponCode;
	}

	public void setSellerCouponCode(String sellerCouponCode) {
		this.sellerCouponCode = sellerCouponCode;
	}

	public BigDecimal getRegionDiscountValue() {
		return regionDiscountValue;
	}

	public void setRegionDiscountValue(BigDecimal regionDiscountValue) {
		this.regionDiscountValue = regionDiscountValue;
	}

	public List<BigDecimal> getOrderItemWeightsOnRegionDiscount() {
		return orderItemWeightsOnRegionDiscount;
	}

	public void setOrderItemWeightsOnRegionDiscount(
			List<BigDecimal> orderItemWeightsOnRegionDiscount) {
		this.orderItemWeightsOnRegionDiscount = orderItemWeightsOnRegionDiscount;
	}

	public BigDecimal getRegionDiscountRatio() {
		return regionDiscountRatio;
	}

	public void setRegionDiscountRatio(BigDecimal regionDiscountRatio) {
		this.regionDiscountRatio = regionDiscountRatio;
	}

	public Integer getSellerCouponSource() {
		return sellerCouponSource;
	}

	public void setSellerCouponSource(Integer sellerCouponSource) {
		this.sellerCouponSource = sellerCouponSource;
	}

	public Integer getSellerCouponType() {
		return sellerCouponType;
	}

	public void setSellerCouponType(Integer sellerCouponType) {
		this.sellerCouponType = sellerCouponType;
	}
}
